/* $Id: Backup.java 62 2008-12-19 01:09:20Z rmceoin $
 * 
 * Copyright 2008 Randy McEoin
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bitsetters.android.passwordsafe;

import android.content.Context;
import android.util.Log;

public class Backup {

	private static boolean debug = false;
	private static final String TAG = "Backup";
	
	public static int CURRENT_VERSION = 2;
	
	private String result="";
	
	Context myCtx=null;

	public Backup(Context ctx) {
		myCtx=ctx;
	}

    public boolean write(String filename) {
    	if (debug) Log.d(TAG,"write("+filename+",)");
    	
		try {
			String path = filename;
			DBHelper dbHelper = new DBHelper(myCtx);
			dbHelper.backup(path);
			dbHelper.close();
			result=myCtx.getString(R.string.backup_complete);
		} catch (Exception e) {
			e.printStackTrace();
			result=myCtx.getString(R.string.backup_failed)+" "+
				e.getLocalizedMessage();
			return false;
		}
		return true;
    }
    public String getResult() {
    	return result;
    }
}
